#include "LinkStack.h"

void InitLStack(LStack *s)
{
    InitDLlist(&s->list);
}

bool SPush(LStack *s, ElementType element)
{
    InsertDLlistTail(&s->list, element);
    return false;
}

void SPop(LStack *s)
{
    RemoveByIndex(&s->list, s->list.len-1);
}

ElementType *GetTop(LStack *s)
{
    if (s->list.len == 0)
    {
        return NULL;
    }
    return &s->list.tail->value;
}

bool IsStackEmpty(LStack *s)
{
    return s->list.len == 0;
}

int GetStackLen(LStack *s)
{
    return s->list.len;
}
